"""
函数


"""
import random


def main():
    print('Hello World')


def generateRandom(x):
    for i in range(x):
        ran = random.randint(1, 20)
        print(ran)


main()
generateRandom(20)
# 查看函数地址
print(generateRandom)

isinstance(2, int)  # 变量 类型

s = {1, 2, 3, 4, 5, 6}
for i in enumerate(s):
    print(i)
enumerate(s)


# 可变参数 装包拆包
def add(*args):
    print(args)


# 默认参数
def asd(a, b=10, c=5):
    print(c)


asd(10, c=2)

print('@' * 40)


# 两个星 字典
def twostars(**kvargs):
    print(kvargs)


twostars(aa=1, bb=2, cc=3)


# 带返回值的函数
def returntest(a, b):
    return a + b


print(returntest(4, 5))

# 多个返回值会放到元祖中

# 全局变量如果是不可变的，在函数中修改需要添加global
global a

print(globals())


def asda():
    aaaa = 'a'
    # nonlocal aaaa
    print(locals())


def testResultPriint():
    print("asdasdasdasdasdda")
    return 10
    print("asdasdasdasdasdda")  # 不执行 运行时 不抱错


testResultPriint()


def my_abs(x):
    if not isinstance(x, (int, float)):
        raise TypeError('bad operand type')
    if x > 0:
        pass


# my_abs('1')
my_abs(1)
